package com.aizhixin.lab.task.service;

import lombok.extern.slf4j.Slf4j;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.aizhixin.lab.common.core.ApiReturnConstants;
import com.aizhixin.lab.common.core.DataValidity;
import com.aizhixin.lab.common.core.LabReportCore;
import com.aizhixin.lab.common.core.UserInforCore;
import com.aizhixin.lab.common.dto.SortDTO;
import com.aizhixin.lab.common.utils.PageJdbcUtil;
import com.aizhixin.lab.company.domain.AccountDomain;
import com.aizhixin.lab.course.classes.domain.LabReportDomain;
import com.aizhixin.lab.course.classes.entity.LabReport;
import com.aizhixin.lab.task.domain.TaskDomain;
import com.aizhixin.lab.task.entity.Task;
import com.aizhixin.lab.task.entity.TaskFile;
import com.aizhixin.lab.task.entity.TaskStuAnswer;
import com.aizhixin.lab.task.entity.TaskStuFile;
import com.aizhixin.lab.task.repository.TaskFileRepository;
import com.aizhixin.lab.task.repository.TaskRepository;
import com.aizhixin.lab.task.repository.TaskStuAnswerRepository;
import com.aizhixin.lab.task.repository.TaskStuFileRepository;

@Slf4j
@Service
@Transactional
public class TaskStuFileService {
	@Autowired
	private TaskStuFileRepository taskStuFileRepository;
//	@Autowired
//	private PageJdbcUtil pageJdbcUtil;

	
	public void save(TaskStuFile taskStuFile) {
		taskStuFileRepository.save(taskStuFile);
	}
	
	public void saveList(List<TaskStuFile> taskStuFiles) {
		taskStuFileRepository.save(taskStuFiles);
	}
	public void deleteByReleaseTaskIdAndStuId(String releaseTaskId,Long stuId){
		taskStuFileRepository.deleteByReleaseTaskIdAndStuId(releaseTaskId, stuId);
	}
	
	public List<TaskStuFile> findAllByStuIdAndReleaseTaskId(Long stuId,String releaseTaskId){
		return taskStuFileRepository.findAllByStuIdAndReleaseTaskIdAndDeleteFlag(stuId, releaseTaskId,DataValidity.VALID.getState());
	}
	public List<TaskStuFile> findByReleaseQuestionIdAndStuId(String releaseQuestionId,Long stuId){
		return taskStuFileRepository.findByReleaseQuestionIdAndStuIdAndDeleteFlag(releaseQuestionId,stuId, DataValidity.VALID.getState());
	}

}
